/**
 * Created by saber on 15/8/13.
 */

var wcApp = angular.module('wc', ['ionic', 'ngResource', 'ionic-material', 'ui.router']);

wcApp.run(['$rootScope', '$ionicHistory', 'ionicMaterialInk','user','request','$http',
    function ($rootScope, $ionicHistory, ionicMaterialInk,user,request,$http) {
        $rootScope.$back = function () {
            $ionicHistory.goBack();
        };
        $rootScope.baseUrl="http://server.backend.wc.isues.net";

        //$rootScope.baseUrl="http://localhost:3029";

        user.hasLogin();
        $http.get($rootScope.baseUrl+'/enroll/getRequest')
            .success(function (resp, code) {
                if (code==200&&resp.code==200&&resp.request.length!=0){
                   request.describe=resp.request.describe;
                    request.firstWish=resp.request.firstWish;
                    request.secondWish=resp.request.secondWish;
                }else{
                    console.log(resp,code);
                }
            });




        return ionicMaterialInk.displayEffect();
    }]);

wcApp.config(['$stateProvider', '$urlRouterProvider', '$locationProvider','$httpProvider',
    function ($stateProvider, $urlRouterProvider, $locationProvider,$httpProvider) {
        $urlRouterProvider.otherwise('/main');
        $stateProvider
            .state('app', {
                url: '',
                template: '<ion-nav-view></ion-nav-view>',
                abstract: true
            })
            .state('app.main', {
                url: '/main',
                templateUrl: 'templates/main.html',
                controller: 'MainCtrl'
            })
            .state('app.weather', {
                url: '/weather',
                templateUrl: 'templates/weather.html',
                controller: 'WeatherCtrl'
            })
            .state('app.verify', {
                url: '/verify',
                templateUrl: 'templates/verify.html',
                controller: 'VerifyCtrl'
            }).state('app.depsList', {
                url: '/departmentList',
                templateUrl: 'templates/depsList.html',
                controller: 'depsSelectCtrl'
            }).state('app.describe', {
                url: '/selfDescribe',
                templateUrl: 'templates/describe.html',
                controller: 'describeCtrl'
            }).state('app.success', {
                url: '/submitSuccess',
                templateUrl: 'templates/success.html',
                controller: 'successCtrl'
            }).state('app.myRequest', {
                url: '/myRequest',
                templateUrl: 'templates/my.html',
                controller: 'myRequestCtrl'
            }).state('app.login', {
                url: '/login',
                templateUrl: 'templates/login.html',
                controller: 'loginCtrl'
            });
        $httpProvider.defaults.withCredentials = true;
        //$locationProvider.html5Mode(true);
    }]);